import 'package:favor_cate/core/model/meal_model.dart';
import 'package:favor_cate/core/viewmodel/favor_meal_veiw_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class DetailFloatActionButton extends StatelessWidget {
  final MealModel meal;

  DetailFloatActionButton(this.meal);

  @override
  Widget build(BuildContext context) {
    return Consumer<FavorMealViewModel>(
        builder: (ctx, model, child) {
          final iconData = model.isFavor(meal) ? Icons.favorite : Icons
              .favorite_border;
          final iconColor = model.isFavor(meal) ? Colors.red : Colors.black;
          return FloatingActionButton(
            backgroundColor: Colors.amber,
            child: Icon(iconData, color: iconColor,),
            onPressed: () {
              model.isFavor(meal) ? model.removeFavor(meal) : model.addFavor(
                  meal);
            },
          );
        }
    );
  }
}
